package com.zpself.module.算法练习.二叉树;

/**
*  节点类
* @author  ZengPeng
* @date  2020/10/9
**/
 class TreeNode {
    int val;
    TreeNode left;
    TreeNode right;

    TreeNode() {
    }

    TreeNode(int val) {
        this.val = val;
    }

    TreeNode(int val, TreeNode left, TreeNode right) {
        this.val = val;
        this.left = left;
        this.right = right;
    }

    public static TreeNode initRoot() {
        TreeNode root = new TreeNode(10);
        TreeNode root_l = new TreeNode(5);
        TreeNode root_r = new TreeNode(15);

        TreeNode root_l_l = new TreeNode(3);
        TreeNode root_l_r = new TreeNode(7);
        TreeNode root_r_l = new TreeNode(13);
        TreeNode root_r_r = new TreeNode(17);

        TreeNode root_l_r_l  = new TreeNode(6);
        TreeNode root_l_r_r  = new TreeNode(8);

        root.left = root_l;
        root.right= root_r;

        root_l.left = root_l_l;
        root_l.right = root_l_r;
        root_r.left = root_r_l;
        root_r.right = root_r_r;

        root_l_r.left = root_l_r_l;
        root_l_r.right = root_l_r_r;
        return root;
    }
}